<script>
export default {
  name: 'AuthRedirect',
  created() {
    var token = this.$route.query['token']
    if (token == null || token === undefined) { return }

    this.$store.dispatch('user/loginByToken', token)
      .then(() => {
        this.$router.push({ path: '/dashboard' })
        // this.loading = false
      })
      .catch(() => {
        // this.loading = false
        this.$router.push({ path: '/login' })
      })

    /* const hash = window.location.search.slice(1)
    if (window.localStorage) {
      window.localStorage.setItem('x-admin-oauth-code', hash)
      window.close()
    }*/
  },
  render: function(h) {
    return h() // avoid warning message
  }
}
</script>
